package com.google.code.ptrends.Application.DAL.entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Embedded;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name = "APP.SESSION_EVENTS")
public class SessionEventEntity implements Serializable{

	private static final long serialVersionUID = 1L;
	private int id;
	private SessionEntity session;
	private String name;
	private String description;
	private Date eventDate;
	private EventTypeEntity eventType;

	public void setId(int id) {
		this.id = id;
	}

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public int getId() {
		return id;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name = "NAME", nullable = false, length = 50)
	public String getName() {
		return name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@Column(name = "DESCRIPTION", nullable = false, length = 255)
	public String getDescription() {
		return description;
	}

	public void setEventDate(Date eventDate) {
		this.eventDate = eventDate == null ? null : new Date(
				eventDate.getTime());
	}

	@Column(name = "EVENT_DATE", nullable = false)
	public Date getEventDate() {
		Date cloned = null;
		if (eventDate != null) {
			cloned = new Date(eventDate.getTime());
		}
		return cloned;
	}

	public void setEventType(EventTypeEntity eventType) {
		this.eventType = eventType;
	}

	@ManyToOne
	@Embedded
	@JoinColumn(name = "EVENT_TYPE_ID", nullable = false)
	public EventTypeEntity getEventType() {
		return eventType;
	}

	public void setSession(SessionEntity session) {
		this.session = session;
	}

	@ManyToOne
	@Embedded
	@JoinColumn(name = "SESSIONS_ID", nullable = false)
	public SessionEntity getSession() {
		return session;
	}

}
